<?php 
class Admin_model extends CI_Model
{
	var $member=array();
	public function __construct()
	{
	}
	
	public function create_admin(){
		$admin_fullname=htmlspecialchars(strip_tags($this->input->post('fullname')),ENT_QUOTES);
		$admin_email=htmlspecialchars(strip_tags($this->input->post('email')),ENT_QUOTES);
		$admin_contact_number=htmlspecialchars(strip_tags($this->input->post('contact_no')),ENT_QUOTES);
		$admin_remark=htmlspecialchars(strip_tags($this->input->post('Remark')),ENT_QUOTES);
		$admin_password=htmlspecialchars(strip_tags($this->input->post('password')),ENT_QUOTES);
		
		$data=array(
				'admin_type'=>'Sub Admin',
				'admin_fullname'=>ucwords($admin_fullname),
				'admin_email'=>$admin_email,
				'admin_contact_number'=>$admin_contact_number,
				'admin_remark'=>$admin_remark,
				'admin_password'=>md5($admin_password),
				'admin_created_by'=>$this->session->userdata('admin_id'),
				'admin_created_date'=>date('Y-m-d H:i:s'),
				'admin_status'=>'active'
			);
		$query=$this->db->insert('scopus_admin',$data);
		if($query){
			return true;
		}
		else {
			return false;
		}
	}
	
	public function manage_admin($id){
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_status !=','Deleted');
		$this->db->where('admin_id',$id);
		$query=$this->db->get('scopus_admin');
		return $query->result();
	}
	
	public function search_admin(){
		$admin_fullname=htmlspecialchars(strip_tags($this->input->post('name_search')),ENT_QUOTES);
		$admin_email=htmlspecialchars(strip_tags($this->input->post('email_search')),ENT_QUOTES);
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_status !=','Deleted');	
		if($admin_fullname!=''){
			 $this->db->like('admin_fullname',$admin_fullname);
		}
		if($admin_email!=''){
			$this->db->like('admin_email',$admin_email);
		}
		$this->db->where('admin_status !=','Deleted');
		$query=$this->db->get('scopus_admin');
		return $query->result();
	}
	
	public function edit_admin($id){
		$admin_id = htmlspecialchars(strip_tags($id),ENT_QUOTES);
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_status !=','Deleted');
		$this->db->where('admin_id',$admin_id);
		$query=$this->db->get('scopus_aaadmin');
		return $query->result();
	}
	
	public function fetch_admin() {
		$where = array('admin_type'=>'Sub Admin', 'admin_status !='=>'Deleted');
        $this->db->where($where);
       	$query=$this->db->get('scopus_admin');
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
   }
	
	public function update_admin($id){
		$admin_id = htmlspecialchars(strip_tags($id),ENT_QUOTES);
		$admin_fullname=htmlspecialchars(strip_tags($this->input->post('fullname')),ENT_QUOTES);
		$admin_email=htmlspecialchars(strip_tags($this->input->post('email')),ENT_QUOTES);
		$admin_contact_number=htmlspecialchars(strip_tags($this->input->post('contact_no')),ENT_QUOTES);
		$admin_remark=htmlspecialchars(strip_tags($this->input->post('Remark')),ENT_QUOTES);
		$admin_password=htmlspecialchars(strip_tags($this->input->post('password')),ENT_QUOTES);
		if($admin_password == '') {
			$data=array(
				'admin_fullname'=>ucwords($admin_fullname),
				'admin_email'=>$admin_email,
				'admin_contact_number'=>$admin_contact_number,
				'admin_remark'=>$admin_remark,
			);	
		}
		else 
			{
			$data=array(
				'admin_fullname'=>ucwords($admin_fullname),
				'admin_email'=>$admin_email,
				'admin_contact_number'=>$admin_contact_number,
				'admin_password'=>md5($admin_password),
				'admin_remark'=>$admin_remark,
			);
		}
		$this->db->where('admin_id',$admin_id);
		$query=$this->db->update('scopus_admin', $data);
		if($query){
			return true;
		}
		else {
			return false;
		}
	}
	
	public function  check_duplicate(){
		
		$email = htmlspecialchars(strip_tags($this->input->post('email')),ENT_QUOTES);
		$id = htmlspecialchars(strip_tags($this->input->post('id')),ENT_QUOTES);
		$this->db->where('admin_email',$email);
		$this->db->where('admin_id !=',$id);
		$query=$this->db->get('scopus_admin');
		if($query->num_rows()==1){
				return	true;
			}
			else {
				return false;
		}
	}
	
	public function delete_admin($id){
		$admin_id = htmlspecialchars(strip_tags($id),ENT_QUOTES);
		$data=array('admin_status' => 'Deleted');
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_id',$admin_id);
		$query=$this->db->update('scopus_admin', $data);
		if($query) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public function active_inactive($id,$status){
		$admin_id = htmlspecialchars(strip_tags($id),ENT_QUOTES);
		$admin_status = htmlspecialchars(strip_tags($status),ENT_QUOTES);
		if($admin_status == 'Active'){
			$data=array('admin_status' => 'Inactive');
		}
		else {
			$data=array('admin_status' => 'Active');
		}
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_id',$admin_id);
		$query=$this->db->update('scopus_admin', $data);
		if($query) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public function get_info(){
		$this->db->where('admin_type',$this->session->userdata('admin_type'));
		$this->db->where('admin_id',$this->session->userdata('admin_id'));
		$query=$this->db->get('scopus_admin');
		if($query->num_rows()==1){
				return	$query->result();
			}
			else {
				return false;
		}
	}
	
	public function update_admin_details(){
		
		$fullname = htmlspecialchars(strip_tags($this->input->post('fullname')),ENT_QUOTES);
		$password = htmlspecialchars(strip_tags($this->input->post('password')),ENT_QUOTES);
		$contact_no = htmlspecialchars(strip_tags($this->input->post('contact_no')),ENT_QUOTES);
		$affiliation = htmlspecialchars(strip_tags($this->input->post('affiliation')),ENT_QUOTES);
		$research = htmlspecialchars(strip_tags($this->input->post('research')),ENT_QUOTES);
		$remark = htmlspecialchars(strip_tags($this->input->post('remark')),ENT_QUOTES);
		$data =array();
		if($password != ''){
			$data['admin_password']=md5($password);
		}
		$data['admin_fullname']= $fullname;
		$data['admin_contact_number']= $contact_no;
		$data['admin_affiliation']= $affiliation;
		$data['admin_research_area']= $research;
		$data['admin_remark']= $remark;
		$this->db->where('admin_type',$this->session->userdata('admin_type'));
		$this->db->where('admin_id',$this->session->userdata('admin_id'));
		$query=$this->db->update('scopus_admin', $data);
		return true;		
	}
	
	public function checkPanelist($value='')
	{
		if (empty($value))
		{
			return FALSE;
		}
				
		$sql_select = array('admin_email');
		$sql_whrere=array('admin_email'=>$value);
		$query = $this->db->select($sql_select)->where($sql_whrere)->get($this->db->dbprefix('admin'));	
	    $result = $query->row();
	    if ($query->num_rows() > 0)
	    {
			return $query->row()->admin_email;
	    }
		return FALSE;
	}
	
	public function addPanelist($value='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		$date=date('Y-m-d H:i:s');
		$id = $this->session->userdata('admin_id');
		$data=array(
			    'admin_type'=>'Panelist',
				'admin_fullname'=>htmlspecialchars(strip_tags($value['fullname']),ENT_QUOTES),
				'admin_email'=>htmlspecialchars(strip_tags($value['email']),ENT_QUOTES),
				'admin_contact_number'=>htmlspecialchars(strip_tags($value['contact_no']),ENT_QUOTES),
				'admin_affiliation'=>htmlspecialchars(strip_tags($value['affiliation']),ENT_QUOTES),
				'admin_research_area'=>htmlspecialchars(strip_tags($value['research']),ENT_QUOTES),
				'admin_remark'=>htmlspecialchars(strip_tags($value['remark']),ENT_QUOTES),
				'admin_password'=>md5($value['password']),
				'admin_created_by'=>$this->session->userdata('admin_id'),
				'admin_created_date'=>htmlspecialchars(strip_tags($date),ENT_QUOTES),
				'admin_status'=>'active'
				);
		$key = $this->common_model->insertData('admin', $data);
		return $key;
	}
	
	public function getPanelistByName($value='', $start='', $end='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		if($value == 'All' && $start == '' && $end == ''){
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted') order by admin_created_date DESC";
			$from = 'admin';
			$this->db->where($where);
			$this->db->select('*');
			$result = $this->db->get($this->db->dbprefix($from));
		}
		else if($value == 'All'){
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted') order by admin_created_date DESC";
			$from = 'admin';
			$result = $this->common_model->selectData($from, '*', $where, '', '', $start, $end);
		}
		else {
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted')";
			$data = array('admin_fullname' => $value);
			$from = 'admin';
			$result = $this->common_model->selectData($from, '*', $where, $data, '', $start, $end);
		}
		
		$resultData=array();
		if($result->num_rows()>0){
			$resultData = $result->result_array();
		}
		return $resultData;
	}

	public function getPanelistByAward($value='', $chief='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		if($chief != '')
		{
			$where = "(award_panelist_award_id='".$value."') AND (award_panelist_type='Chief Panelist') AND (award_panelist_status='Active')";
			$from = 'award_panelist';
		}
		else{
			$where = "(ap.award_panelist_award_id='".$value."') AND (ap.award_panelist_admin_id=a.admin_id) AND (a.admin_type='Panelist') AND (ap.award_panelist_status='Active')";
			$from = 'award_panelist ap, admin a';
		}
		$this->db->where($where);
		$this->db->select('*');
		$result = $this->db->get($this->db->dbprefix($from));
				
		$resultData=array();
		if($result->num_rows()>0){
			$resultData = $result->result_array();
		}
		return $resultData;
	}
	
	public function getApplicantBYAward($award_id){
		$this->db->where('user_application_award_id',$award_id);
		$query = $this->db->get('scopus_user_application');
		return $query->result_array();
	}
	
	public function getPanelistByAff($value='', $start='', $end='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		if($value == 'All' && $start == '' && $end == ''){
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted') order by admin_created_date DESC";
			$from = 'admin';
			$this->db->where($where);
			$this->db->select('*');
			$result = $this->db->get($this->db->dbprefix($from));
		}
		else if($value == 'All'){
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted') order by admin_created_date DESC";
			$from = 'admin';
			$result = $this->common_model->selectData($from, '*', $where, '', '', $start, $end);
		}
		else {
			$where = "(admin_type='Panelist') AND (admin_status!='Deleted')";
			$data = array('admin_affiliation' => $value);
			$from = 'admin';
			$result = $this->common_model->selectData($from, '*', $where, $data, '', $start, $end);
		}
		
		$resultData=array();
		if($result->num_rows()>0){
			$resultData = $result->result_array();
		}
		return $resultData;
	}
	
	public function getPanelistById($value='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		$where = "(admin_id='".$value."') AND (admin_status!='Deleted')";
		$from = 'admin';
		$result = $this->common_model->selectData($from, '*', $where, '');
		
		$resultData=array();
		if($result->num_rows()>0){
			$resultData = $result->result_array();
		}
		return $resultData;
	}
	
	public function updatePanelistStatus($id, $value='')
	{
		if (empty($value))
		{
			return FALSE;
		}
		$status = array('admin_status' => $value);
		$where = array('admin_id' => $id);
		$this->db->where($where);
		$this->db->update($this->db->dbprefix('admin'), $status);
	}
	
	public function updatePanelist($value="")
	{
		if (empty($value))
		{
			return FALSE;
		}
		$date=date('Y-m-d H:i:s');
		$id = $value['admin_id'];
		$data=array(
				'admin_type'=> 'Panelist',
				'admin_fullname'=>htmlspecialchars(strip_tags($value['fullname']),ENT_QUOTES),
				'admin_email'=>htmlspecialchars(strip_tags($value['email']),ENT_QUOTES),
				'admin_contact_number'=>htmlspecialchars(strip_tags($value['contact_no']),ENT_QUOTES),
				'admin_affiliation'=>htmlspecialchars(strip_tags($value['affiliation']),ENT_QUOTES),
				'admin_research_area'=>htmlspecialchars(strip_tags($value['research']),ENT_QUOTES),
				'admin_remark'=>htmlspecialchars(strip_tags($value['remark']),ENT_QUOTES),
				'admin_password'=>md5($value['password']),
				'admin_created_by'=>$this->session->userdata('admin_id'),
				'admin_created_date'=>htmlspecialchars(strip_tags($date),ENT_QUOTES),
				'admin_status' => 'Active'
				);
		$where = array('admin_id' => $id);
		$this->db->where($where);
		$this->db->update($this->db->dbprefix('admin'), $data);
	}
	
	public function updatePanelist_profile(){
		$data=array();
		
		$data['admin_fullname'] = ucwords(htmlspecialchars(strip_tags($this->input->post('fullname')),ENT_QUOTES));
		if($this->input->post('password') != NULL){
			$data['admin_password'] = md5(ucwords(htmlspecialchars(strip_tags($this->input->post('password')),ENT_QUOTES)));
		}
		$data['admin_contact_number'] = ucwords(htmlspecialchars(strip_tags($this->input->post('contact_no')),ENT_QUOTES));
		$data['admin_affiliation'] = ucfirst(htmlspecialchars(strip_tags($this->input->post('affiliation')),ENT_QUOTES));
		$data['admin_research_area'] = ucfirst(htmlspecialchars(strip_tags($this->input->post('research')),ENT_QUOTES));
		$data['admin_remark'] = ucfirst(htmlspecialchars(strip_tags($this->input->post('remark')),ENT_QUOTES));
		$this->db->where('admin_id',$this->session->userdata('admin_id'));
		$query = $this->db->update('scopus_admin', $data);
		if($query){
			return true;
		}
		else {
			return false;
		}
	}
	
	public function getAwardapplication_panalist(){
		$this->db->where('award_panelist_admin_id',$this->session->userdata('admin_id'));
		//$this->db->where('award_panelist_type','Panelist');
		$this->db->where('award_panelist_status','Active');
		$query=$this->db->get('scopus_award_panelist');
		return $query->result();
		
	}
	
	public function award_name($id){
		$this->db->where('award_id',$id);
		$this->db->where('award_status','Active');
		$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
		$query1 = $this->db->get();
		return $query1->result();
	}
	
	public function get_inchargename($id){
		$this->db->where('admin_id',$id);
		$this->db->where('admin_status','Active');
		$query2 = $this->db->get('scopus_admin');
		return $query2->result();
		
	}
	public function get_chief_panelist($id){
		$this->db->where('award_panelist_award_id',$id);
		$this->db->where('award_panelist_type',"Chief Panelist");
		$query3 = $this->db->get('scopus_award_panelist');
		$q = $query3->result();
		if($q){
			$this->db->where('admin_id',$q[0]->award_panelist_admin_id);
			$q_result = $this->db->get('scopus_admin');
			return $q_result->result();
		}
	}
	
	public function get_all_panelist($id){
		$this->db->where('award_panelist_award_id',$id);
		$query = $this->db->get('scopus_award_panelist');
		return $query->result();
	}
	
	public function report1(){
		$this->db->select('admin_fullname,admin_email,admin_contact_number');
		$this->db->where('admin_type','Sub Admin');
		$this->db->where('admin_status !=','Deleted');	
		$query = $this->db->get('scopus_admin');
		return $query->result_array();
	}
	
	public function report1_search(){
		$admin_fullname=htmlspecialchars(strip_tags($this->input->post('name')),ENT_QUOTES);
		$admin_email=htmlspecialchars(strip_tags($this->input->post('email')),ENT_QUOTES);
		
		$this->db->where('admin_status !=','Deleted');	
		$this->db->where('admin_type','Sub Admin');
		if($admin_fullname!=''){
			 $this->db->like('admin_fullname',$admin_fullname);
		}
		if($admin_email!=''){
			$this->db->like('admin_email',$admin_email);
		}
		$query = $this->db->get('scopus_admin');
		return $query->result_array();
	}
	
	public function report2(){
		$this->db->select('admin_fullname,admin_affiliation,admin_email,admin_contact_number');
		$this->db->where('admin_type','Panelist');
		$this->db->where('admin_status !=','Deleted');	
		$query = $this->db->get('scopus_admin');
		return $query->result_array();
	}
	
	public function report2_search(){
		$panelist_fullname=htmlspecialchars(strip_tags($this->input->post('name')),ENT_QUOTES);
		$panelist_affiliation=htmlspecialchars(strip_tags($this->input->post('affiliation')),ENT_QUOTES);
		$this->db->where('admin_status !=','Deleted');	
		$this->db->where('admin_type','Panelist');
		if($panelist_fullname!=''){
			 $this->db->like('admin_fullname',$panelist_fullname);
		}
		if($panelist_affiliation!=''){
			$this->db->like('admin_affiliation',$panelist_affiliation);
		}
		$query = $this->db->get('scopus_admin');
		
		return $query->result_array();
	}
	
	public function event_report(){
		$this->db->where('award_status','Active');
		$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_award.award_created_date,scopus_award.award_current_status,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
		$query1 = $this->db->get();
		return $query1->result();
	}
	
	public function award_incharge($id){
		$this->db->where('admin_id',$id);
		$query = $this->db->get('scopus_admin');
		return $query->result();
	}
	
	public function award_panelist($id,$panelist){
		$this->db->where('award_panelist_award_id',$id);
		if($panelist == 'Chief Panelist') {
			$this->db->where('award_panelist_type',$panelist);
		}
		$this->db->where('award_panelist_status','Active');
		$query = $this->db->get('scopus_award_panelist');
		$result = $query->result();
		for($i=0; $i < count($result); $i++){
			$data['panelist_details'] = $this->admin_model->award_incharge($result[$i]->award_panelist_admin_id);
		}
		return $data['panelist_details'];
	}
	
	public function total_applicant($id){
		$this->db->where('user_application_award_id',$id);
		$this->db->where('user_application_application_status','Complete');
		$this->db->where('user_application_status','Active');
		$query = $this->db->get('scopus_user_application');
		return $query->result();
	}
	
	public function total_panelist($id){
		$this->db->where('award_panelist_award_id',$id);
		$this->db->where('award_panelist_type','Panelist');
		$this->db->where('award_panelist_status','Active');
		$query = $this->db->get('scopus_award_panelist');
		return $query->result();
	}
	
	public function report3_search(){
		$eventname=htmlspecialchars(strip_tags($this->input->post('eventname')),ENT_QUOTES);
		$awardname=htmlspecialchars(strip_tags($this->input->post('awardname')),ENT_QUOTES);
		
		if($awardname!=''){
			 $this->db->like('award_name',$awardname);
			 $query = $this->db->get('scopus_award');
			 $result = $query->result();
			 for($i=0; $i < count($result); $i++){
			 	$this->db->where('award_status','Active');
				$this->db->where('award_id', $result[$i]->award_id);
				$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_award.award_created_date,scopus_award.award_current_status,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
				$query1 = $this->db->get();
				return  $query1->result();
			 }
			 
		}
		if($eventname!=''){
			$this->db->like('event_name',$eventname);
			$query = $this->db->get('scopus_event');
			$result = $query->result();
			for($i=0; $i < count($result); $i++){
			 	$this->db->where('award_status','Active');
				$this->db->where('event_id', $result[$i]->event_id);
				$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_award.award_created_date,scopus_award.award_current_status,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
				$query1 = $this->db->get();
				return  $query1->result();
			 }
		}
	}
	
	public function getAllpnelist(){
		$this->db->where('award_panelist_status','Active');
		$this->db->select('scopus_award_panelist.award_panelist_award_id, scopus_award_panelist.award_panelist_admin_id, scopus_award_panelist.award_panelist_type,scopus_admin.admin_fullname,scopus_admin.admin_email,scopus_admin.admin_contact_number')->from('scopus_award_panelist')->join('scopus_admin', 'scopus_admin.admin_id = scopus_award_panelist.award_panelist_admin_id');
		$query1 = $this->db->get();
		return $query1->result();
	}
	
	public function event_award($id){
		$this->db->where('award_status','Active');
		$this->db->where('award_id', $id);
		$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_award.award_created_date,scopus_award.award_current_status,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
		$query1 = $this->db->get();
		return  $query1->result();
	}
	
	public function searchByevent(){
		$eventname=htmlspecialchars(strip_tags($this->input->post('eventname')),ENT_QUOTES);
		if($eventname!=''){
			$this->db->where('event_status','Active');
			$this->db->like('event_name',$eventname);
			$query = $this->db->get('scopus_event');
			return $query->result();
		}else {
			return false;
		}
	}
	
	public function awardByevent($id){
		$this->db->where('award_event_id',$id);
		$query = $this->db->get('scopus_award');
		$result = $query->result();
		
		for($m=0; $m<count($result); $m++){
			$this->db->where('award_panelist_award_id',$result[$m]->award_id);
			$query1 = $this->db->get('scopus_award_panelist');
			$result1[] = $query1->result();
		}
		
		return $result1;
	}
	
	public function applicantBYEvent(){
		$this->db->where('award_status','Active');
		$query = $this->db->get('scopus_award');
		return $query->result();
	}
	
	public function applicantBY_Event(){
		$this->db->where('award_status','Active');
		$this->db->select('scopus_award.award_id, scopus_award.award_incharge_id, scopus_award.award_current_status, scopus_award.award_name,scopus_award.award_created_date,scopus_award.award_current_status,scopus_event.event_name,scopus_event.event_description')->from('scopus_event')->join('scopus_award', 'scopus_event.event_id = scopus_award.award_event_id');
		$query1 = $this->db->get();
		return  $query1->result();
	}
	
	public function total_applicantByEvent($id){
		$this->db->where('user_application_award_id',$id);
		$this->db->where('user_application_status','Active');
		$query = $this->db->get('scopus_user_application');
		return $query->num_rows(); 
	}
	
	public function applicantBycountry($id){
		$this->db->where('user_application_award_id',$id);
		$this->db->where('user_application_status','Active');
		$this->db->select('scopus_user_application.user_application_field5, COUNT(scopus_user_application.user_application_field5) as total,scopus_master_country.country_name')->from('scopus_user_application')->join('scopus_master_country','scopus_user_application.user_application_field5 = scopus_master_country.country_id');
 		$this->db->group_by('user_application_field5'); 
		$query = $this->db->get();
		return $query->result();
	}
	public function event_reportBYapplicant(){
		$this->db->where('award_status','Active');
		$this->db->select('scopus_event.event_name,scopus_award.award_name,COUNT(scopus_user_application.user_application_award_id) as total_applicant,COUNT(scopus_user_application.user_application_field5) as applicantBycountry,scopus_award.award_current_status');
		$this->db->from('scopus_award');	
		$this->db->join('scopus_event', 'scopus_event.event_id = scopus_award.award_event_id', 'left');
		$this->db->join('scopus_user_application', 'scopus_user_application.user_application_award_id = scopus_award.award_id', 'left');
		$this->db->join('scopus_master_country','scopus_user_application.user_application_field5 = scopus_master_country.country_id');
		$query = $this->db->get();
		return $query->result_array();	
	}
	
	public function Getwinner(){
		$this->db->where('award_winner_status','Active');
		$this->db->select('scopus_event.event_name as Event,scopus_award.award_name as Award,scopus_award_winner.award_winner_applicant_name as Winner,scopus_award_winner.award_winner_prize as Rank,scopus_user_application.user_application_field8 as Affiliation');
		$this->db->from('scopus_award_winner');
		$this->db->join('scopus_award', 'scopus_award.award_id = scopus_award_winner.award_winner_award_id', 'left');
		$this->db->join('scopus_event', 'scopus_event.event_id = scopus_award.award_id', 'left');
		$this->db->join('scopus_user_application', 'scopus_user_application.user_application_applicant_id = scopus_award_winner.award_winner_applicant_id', 'left');
		$query = $this->db->get();
		return $query->result_array();
	}
}
/* End of file common_model.php */
/* Location: ./application/models/common_model.php */